<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Collecting monitoring data using legacy collectors | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'collecting-monitoring-data.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/collecting-monitoring-data.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/collecting-monitoring-data.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/collecting-monitoring-data.html" rel="nofollow" target="_blank">../en/collecting-monitoring-data.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="monitor-elasticsearch-cluster.html">Monitor a cluster</a></span>
»
<span class="breadcrumb-node">Collecting monitoring data using legacy collectors</span>
</div>
<div class="navheader">
<span class="prev">
<a href="config-monitoring-indices.html">« Configuring indices for monitoring</a>
</span>
<span class="next">
<a href="es-monitoring-collectors.html">Collectors »</a>
</span>
</div>
<div class="chapter xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="collecting-monitoring-data"></a>Collecting monitoring data using legacy collectors<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/monitoring/collecting-monitoring-data.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>

<div class="important admon">
<div class="icon"></div>
<div class="admon_content">
<p>Metricbeat is the recommended method for collecting and shipping monitoring
data to a monitoring cluster.</p>
<p>If you have previously configured legacy collection methods, you should migrate
to using Metricbeat collection methods. Use either Metricbeat collection or
legacy collection methods; do not use both.</p>
<p>Learn more about <a class="xref" href="configuring-metricbeat.html" title="Collecting Elasticsearch monitoring data with Metricbeat"><em>Collecting monitoring data with Metricbeat</em></a>.</p>
</div>
</div>
<p>If you enable the Elastic monitoring features in your cluster, you can
optionally collect metrics about Elasticsearch. By default, monitoring is enabled but
data collection is disabled.</p>
<p>This method involves sending the metrics to the monitoring cluster by using
exporters. For the recommended method, see <a class="xref" href="configuring-metricbeat.html" title="Collecting Elasticsearch monitoring data with Metricbeat"><em>Collecting monitoring data with Metricbeat</em></a>.</p>
<p>Advanced monitoring settings enable you to control how frequently data is
collected, configure timeouts, and set the retention period for locally-stored
monitoring indices. You can also adjust how monitoring data is displayed.</p>
<p>To learn about monitoring in general, see <a class="xref" href="monitor-elasticsearch-cluster.html" title="Monitor a cluster">Monitor a cluster</a>.</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
<p>Configure your cluster to collect monitoring data:</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
Verify that the <code class="literal">xpack.monitoring.enabled</code> setting is <code class="literal">true</code>, which is its
default value, on each node in the cluster. For more information, see
<a class="xref" href="monitoring-settings.html" title="Monitoring settings in Elasticsearch">Monitoring settings</a>.
</li>
<li class="listitem">
<p>Verify that the <code class="literal">xpack.monitoring.elasticsearch.collection.enabled</code> setting
is <code class="literal">true</code>, which is its default value, on each node in the cluster.</p>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>You can specify this setting in either the <code class="literal">elasticsearch.yml</code> on each
node or across the cluster as a dynamic cluster setting. If Elasticsearch
security features are enabled, you must have <code class="literal">monitor</code> cluster privileges to
view the cluster settings and <code class="literal">manage</code> cluster privileges to change them.</p>
</div>
</div>
<p>For more information, see <a class="xref" href="monitoring-settings.html" title="Monitoring settings in Elasticsearch">Monitoring settings</a> and <a class="xref" href="cluster-update-settings.html" title="Cluster update settings API">Cluster update settings</a>.</p>
</li>
<li class="listitem">
<p>Set the <code class="literal">xpack.monitoring.collection.enabled</code> setting to <code class="literal">true</code> on each
node in the cluster. By default, it is is disabled (<code class="literal">false</code>).</p>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>You can specify this setting in either the <code class="literal">elasticsearch.yml</code> on each
node or across the cluster as a dynamic cluster setting. If Elasticsearch
security features are enabled, you must have <code class="literal">monitor</code> cluster privileges to
view the cluster settings and <code class="literal">manage</code> cluster privileges to change them.</p>
</div>
</div>
<p>For example, use the following APIs to review and change this setting:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET _cluster/settings

PUT _cluster/settings
{
  "persistent": {
    "xpack.monitoring.collection.enabled": true
  }
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1145.console"></div>
<p>Alternatively, you can enable this setting in Kibana. In the side navigation,
click <span class="strong strong"><strong>Monitoring</strong></span>. If data collection is disabled, you are prompted to turn it
on.</p>
<p>For more
information, see <a class="xref" href="monitoring-settings.html" title="Monitoring settings in Elasticsearch">Monitoring settings</a> and <a class="xref" href="cluster-update-settings.html" title="Cluster update settings API">Cluster update settings</a>.</p>
</li>
<li class="listitem">
<p>Optional: Specify which indices you want to monitor.</p>
<p>By default, the monitoring agent collects data from all Elasticsearch indices.
To collect data from particular indices, configure the
<code class="literal">xpack.monitoring.collection.indices</code> setting. You can specify multiple indices
as a comma-separated list or use an index pattern to match multiple indices. For
example:</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.monitoring.collection.indices: logstash-*, index1, test2</pre>
</div>
<p>You can prepend <code class="literal">-</code> to explicitly exclude index names or
patterns. For example, to include all indices that start with <code class="literal">test</code> except
<code class="literal">test3</code>, you could specify <code class="literal">test*,-test3</code>. To include system indices such as
.security and .kibana, add <code class="literal">.*</code> to the list of included names.
For example <code class="literal">.*,test*,-test3</code></p>
</li>
<li class="listitem">
Optional: Specify how often to collect monitoring data. The default value for
the <code class="literal">xpack.monitoring.collection.interval</code> setting 10 seconds. See
<a class="xref" href="monitoring-settings.html" title="Monitoring settings in Elasticsearch">Monitoring settings</a>.
</li>
</ol>
</div>
</li>
<li class="listitem">
<p>Identify where to store monitoring data.</p>
<p>By default, the data is stored on the same cluster by using a
<a class="xref" href="local-exporter.html" title="Local exporters"><code class="literal">local</code> exporter</a>. Alternatively, you can use an <a class="xref" href="http-exporter.html" title="HTTP exporters"><code class="literal">http</code> exporter</a> to send data to
a separate <em>monitoring cluster</em>.</p>
<div class="important admon">
<div class="icon"></div>
<div class="admon_content">
<p>The Elasticsearch monitoring features use ingest pipelines, therefore the
cluster that stores the monitoring data must have at least one
<a class="xref" href="ingest.html" title="Ingest node">ingest node</a>.</p>
</div>
</div>
<p>For more information about typical monitoring architectures,
see <a class="xref" href="how-monitoring-works.html" title="How monitoring works"><em>How it works</em></a>.</p>
</li>
<li class="listitem">
<p>If you choose to use an <code class="literal">http</code> exporter:</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
<p>On the cluster that you want to monitor (often called the <em>production cluster</em>),
configure each node to send metrics to your monitoring cluster. Configure an
HTTP exporter in the <code class="literal">xpack.monitoring.exporters</code> settings in the
<code class="literal">elasticsearch.yml</code> file. For example:</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.monitoring.exporters:
  id1:
    type: http
    host: ["http://es-mon-1:9200", "http://es-mon2:9200"]</pre>
</div>
</li>
<li class="listitem">
<p>If the Elastic security features are enabled on the monitoring cluster, you
must provide appropriate credentials when data is shipped to the monitoring cluster:</p>
<div class="olist lowerroman">
<ol class="lowerroman" type="i">
<li class="listitem">
Create a user on the monitoring cluster that has the
<a class="xref" href="built-in-roles.html" title="Built-in roles"><code class="literal">remote_monitoring_agent</code> built-in role</a>.
Alternatively, use the
<a class="xref" href="built-in-users.html" title="Built-in users"><code class="literal">remote_monitoring_user</code> built-in user</a>.
</li>
<li class="listitem">
<p>Add the user ID and password settings to the HTTP exporter settings in the
<code class="literal">elasticsearch.yml</code> file on each node.<br></p>
<p>For example:</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.monitoring.exporters:
  id1:
    type: http
    host: ["http://es-mon-1:9200", "http://es-mon2:9200"]
    auth.username: remote_monitoring_user
    auth.password: YOUR_PASSWORD</pre>
</div>
</li>
</ol>
</div>
</li>
<li class="listitem">
<p>If you configured the monitoring cluster to use
<a class="xref" href="configuring-tls.html" title="Encrypting communications in Elasticsearch">encrypted communications</a>, you must use the HTTPS protocol in
the <code class="literal">host</code> setting. You must also specify the trusted CA certificates that will
be used to verify the identity of the nodes in the monitoring cluster.</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>To add a CA certificate to an Elasticsearch node’s trusted certificates, you can
specify the location of the PEM encoded certificate with the
<code class="literal">certificate_authorities</code> setting. For example:</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.monitoring.exporters:
  id1:
    type: http
    host: ["https://es-mon1:9200", "https://es-mon2:9200"]
    auth:
      username: remote_monitoring_user
      password: YOUR_PASSWORD
    ssl:
      certificate_authorities: [ "/path/to/ca.crt" ]</pre>
</div>
</li>
<li class="listitem">
<p>Alternatively, you can configure trusted certificates using a truststore
(a Java Keystore file that contains the certificates). For example:</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.monitoring.exporters:
  id1:
    type: http
    host: ["https://es-mon1:9200", "https://es-mon2:9200"]
    auth:
      username: remote_monitoring_user
      password: YOUR_PASSWORD
    ssl:
      truststore.path: /path/to/file
      truststore.password: password</pre>
</div>
</li>
</ul>
</div>
</li>
</ol>
</div>
</li>
<li class="listitem">
Configure your cluster to route monitoring data from sources such as Kibana,
Beats, and Logstash to the monitoring cluster. For information about configuring
each product to collect and send monitoring data, see <a class="xref" href="monitor-elasticsearch-cluster.html" title="Monitor a cluster">Monitor a cluster</a>.
</li>
<li class="listitem">
<p>If you updated settings in the <code class="literal">elasticsearch.yml</code> files on your production
cluster, restart Elasticsearch. See <a class="xref" href="stopping-elasticsearch.html" title="Stopping Elasticsearch"><em>Stopping Elasticsearch</em></a> and <a class="xref" href="starting-elasticsearch.html" title="Starting Elasticsearch"><em>Starting Elasticsearch</em></a>.</p>
<div class="tip admon">
<div class="icon"></div>
<div class="admon_content">
<p>You may want to temporarily <a href="modules-cluster.html" class="ulink" target="_top">disable shard
allocation</a> before you restart your nodes to avoid unnecessary shard
reallocation during the install process.</p>
</div>
</div>
</li>
<li class="listitem">
Optional:
<a class="xref" href="config-monitoring-indices.html" title="Configuring indices for monitoring">Configure the indices that store the monitoring data</a>.
</li>
<li class="listitem">
<a href="https://www.elastic.co/guide/en/kibana/7.7/monitoring-data.html" class="ulink" target="_top">View the monitoring data in Kibana</a>.
</li>
</ol>
</div>





</div>
<div class="navfooter">
<span class="prev">
<a href="config-monitoring-indices.html">« Configuring indices for monitoring</a>
</span>
<span class="next">
<a href="es-monitoring-collectors.html">Collectors »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>